/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package medicina;

import java.io.File;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRExporter;
import net.sf.jasperreports.engine.JRExporterParameter;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.engine.export.JRHtmlExporter;
import net.sf.jasperreports.engine.export.JRPdfExporter;
import net.sf.jasperreports.engine.util.JRLoader;
import static org.apache.poi.hssf.usermodel.HeaderFooter.file;

/**
 *
 * @author ERWIN
 */
public class Medicina {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws ClassNotFoundException, SQLException, JRException {
        Class.forName("com.mysql.jdbc.Driver"); 
        Connection conexion = DriverManager.getConnection("jdbc:mysql://localhost:3306/hospital", "root", "edema23");
        
        File r = new File("historialClinico.jasper");        
        JasperReport reporte = (JasperReport) JRLoader.loadObject(r);
        JasperPrint jasperPrint = JasperFillManager.fillReport(reporte, null, conexion);
        JRExporter exporter = new JRPdfExporter();
        exporter.setParameter(JRExporterParameter.JASPER_PRINT,jasperPrint); 
        exporter.setParameter(JRExporterParameter.OUTPUT_FILE,new java.io.File("reportePDF.pdf"));
        exporter.exportReport();
        System.out.println("Hola Mundo Este es mi primer subversion!! :)");
       }
    
    
}
